package com.example.server.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;

/**
 * @Author: YAOZUN
 * @Date: Created in 17:32 2018/12/16 0016
 * @Description:
 */
public class RmiProxyFactoryUtil {

    private static Logger logger = LoggerFactory.getLogger(RmiProxyFactoryUtil.class);

    public static <T> T geRmiClientBean(Class<T> clazz,String url) throws Exception
    {
        // 客户端连接工厂,这里只是做了最简单的实例化，还可以设置超时时间，密码等安全参数
        RmiProxyFactoryBean factory = new RmiProxyFactoryBean();
        factory.setServiceUrl(url);
        factory.setServiceInterface(clazz);
        return (T)factory.getObject();
    }

}
